<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML>
<html>
  <head>
    <title>header</title>
    <script src="<%=request.getContextPath()%>/resources/js/common.js"></script>
    <script src="<%=request.getContextPath()%>/resources/layer/layer.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/resources/js/my97datepicker/WdatePicker.js"></script>
    <script type="text/javascript">
    	$(function(){
    		//选择文件时显示名称
    		$("input[type='file']").change(function(){
    			$(".pop_cont_text").text($(this).val());
    		});
    		
    		$.message("${flashtype}", "${flashmessage}");
    		
	    	/*  id="checkAll" */
	    	$("#checkAll").click(function(){
	    		$("input[type='checkbox']").prop("checked", $("#checkAll").is(":checked"));
	    	});
	    	
	    	//对当前勾线的换背景颜色
	    	$("input[type='checkbox']").click(function(){
	    		if($(this).is(':checked')){
	    			$(this).closest("table").find("tr").css({"background":""});
		    		$(this).closest("tr").css({"background":"#5cbdaa"});
	    		}else{
		    		$(this).closest("tr").css({"background":""});
	    		}
	    	});
	    	
	    	$(".delete").click(function(){
	    		if($(".ids:checked").length == 0){
	    			return false;
	    		}
	    		if(confirm("是否删除？")){
	    			$.loading();
	    			$.ajax({
	    				url: "delete.do",
	    				data:{
	    					ids: function(){
	    						var chk_value =[]; 
	    						$(".ids:checked").each(function(){ 
	    							chk_value.push($(this).val()); 
	    						}); 
	    						return chk_value;
	    					}
	    				},
	    				type: "post",
	    				success: function(data){
	    					$.loadingout();
	    					if(data){
	    						$.message("success", "操作成功");
	    					}else{
	    						$.message("error", "操作失败");
	    					}
	    					setTimeout(function() {
	    						location.reload(true);
	    					}, 3000);
	    				}
	    			});
	    		}
	    	});
	    	
	    	$(".download").click(function(){
				var arr = new Array();
				arr = $("input[type='checkbox']:checked");
				if(arr.length<1 || arr.length== 1 && arr[0].value == "-1"){
					$.message("warn","请选择要导出选项");
					return false;
				}
				if(!confirm("确定导出?")){
					return false;
				}
				var chk_value =[]; 
				arr.each(function(){ 
					chk_value.push($(this).val()); 
				}); 
				
				//location.href = "download.do?ids="+chk_value;
				
				var form = $("<form></form>");
		        form.attr('action', 'download.do');
		        form.attr('method','post');
		        input1 = $("<input type='hidden' name='ids' />");
		        input1.attr('value', chk_value);
		        form.append(input1);
		        form.appendTo("body");
		        form.css('display','none');
		        console.log(form);
		        form.submit();
		        
				return false;
			});
	    	
	    	//控制权限
	    	$(".checkAuth").each(function(){
	    		var authorities = '${authorities}';
	    		console.log(authorities);
	    		var auth = $(this).attr("auth");
	    		if(authorities.indexOf(auth) < 0){
	    			$(this).remove();
	    		}
	    	});
    	});
    	
    </script>
  </head>
  <body>
  
  
  </body>
</html>
